<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateProductSkusTable extends Migration
{
    public function up()
    {
        Schema::create('product_skus', function (Blueprint $table) {
            $table->id();
	        $table->unsignedBigInteger('product_id')->index()->default(0)->comment('belongs to this product');
	        $table->string('name')->nullable()->comment('name of sku');
	        $table->string('code')->nullable()->index()->comment('product sku number');
	        $table->string('brief')->nullable()->comment('description of sku');
	        
	        $table->string('pic')->nullable()->comment('sku cover picture');
	        $table->text('attr_value')->nullable();
	        $table->string('attr_value_index')->nullable()->index();
	
	        $table->decimal('price_cost', 10, 2)->nullable()->comment('cost price of sku');
	        $table->decimal('price', 10, 2)->nullable()->comment('normal selling price of sku');
	        $table->decimal('price_vip', 10, 2)->nullable()->comment('member price of sku');
	        $table->decimal('price_apple', 10, 2)->nullable()->comment('apple price of sku');
	        $table->unsignedInteger('stock')->default(0)->comment('sku stock number');
	
	        $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('product_skus');
    }
}
